<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>Trả lời khảo sát</title>
	
	<!-- Load main style css -->
	<%@ include file="../include-file/main-style.jsp" %>
	
	<!-- Load script -->
	<script src="<c:url value="/resources/js/form-control.js" />"></script>
	
</head>
<body>
	<div class="main-content">
		<!-- Menu bar -->
		<%@ include file="../include-file/header-menu.jsp" %>
		
		<div class="body-content">
			<div class="top-right-button">
				<a href="./camp-detail?campId=${model.campId}" class="btn btn-primary"><div class="button-box">Danh sách khảo sát</div></a>
				<br>
				<br>
	<%-- 			<a href="./quest-create?surveyId=${model.survey.surveyId}" class="btn btn-warning"><div class="button-box">Trả lời khảo sát tiếp theo</div></a> --%>
			
			
			</div>
			<div class="title-text">
				<h3>${model.survey.name}</h3>
			</div>
			
			
			<div class="list-itemTemp">
				Danh sách câu hỏi
				<form:form method="post" action="./answer-result-save/${model.survey.surveyId}" modelAttribute="survey" id="answerform" name="answerform">
					<ol class="rounded-listTemp">
						<c:set var="answerIndex" scope="session" value="1"/>
						
						<c:forEach var="questAnsList" items="${model.listQuestAnsList}">
							<li><a href="#">${questAnsList.question.questContent}</a>
							<c:choose>
								  <c:when test="${questAnsList.question.limitAnswer>'0'}">
								    (Chọn nhiều nhất ${questAnsList.question.limitAnswer} đáp án)
								  </c:when>
							 </c:choose>
							
								<c:forEach var="answer" items="${questAnsList.answerList }">
									<div class="form-group">
						              <label class="checkbox" for="checkbox${answerIndex}">
						                <input type="checkbox" data-toggle="checkbox" value="${answer.answerId}"
						                	 id="checkbox${answerIndex}" name="checkbox${questAnsList.question.questId}">
						                	${answer.answerContent }
						                	<c:set var="answerIndex" value="${answerIndex + 1}"/>
						                	
						              </label>
						            </div>
								</c:forEach>
							</li>
							
							<script type="text/javascript">
								checkboxlimit(document.forms.answerform.checkbox${questAnsList.question.questId}, ${questAnsList.question.limitAnswer});
							</script>
						</c:forEach>
					</ol>
					<button type="submit" class="btn btn-sm btn-primary">Submit</button>
				</form:form>
				
				
			</div>
		</div>
	</div>
	
	<%@ include file="../include-file/footer-script.jsp" %>
	
</body>
</html>